<html>
<head><meta charset="utf-8"><title>enabling debug logging for rustc in-tree tests · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html">enabling debug logging for rustc in-tree tests</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216174152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216174152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216174152">(Nov 10 2020 at 05:37)</a>:</h4>
<p>How do i enable Rust compiler debug assertions (specifically, so I can see <code>debug!</code> log messages in the library APIs I'm testing) when running <code>#[cfg(test)]</code> in-tree unit tests? </p>
<p>I'm writing some unit tests in <code>rustc_mir</code> for coverage, and <code>debug</code> macros (including logs and debug_asserts) are not executing, even though debug assertions work for the <code>rustc</code> compiler itself. (I also tried setting <code>optimize-tests=false</code> in config.toml, and a clean build, but it made no difference.) </p>
<p>The command I use to run tests and see the stdout/stderr is: <code>RUSTC_LOG="rustc_mir::transform::coverage=debug" ./x.py test compiler/rustc_mir --rustc-args "-C debug-assertions=on" --test-args "--show-output coverage"</code></p>
<p>(It looks like <code>--rustc-args</code> is ignored, even with invalid flags/args.)</p>



<a name="216174820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216174820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216174820">(Nov 10 2020 at 05:55)</a>:</h4>
<p><span class="user-mention" data-user-id="296355">@Rich Kadel</span> debug-logging = true</p>



<a name="216174875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216174875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216174875">(Nov 10 2020 at 05:57)</a>:</h4>
<p>Unless you mean the logging for tests is being swallowed by compiletest</p>



<a name="216174877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216174877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216174877">(Nov 10 2020 at 05:57)</a>:</h4>
<p>Then you want -vv</p>



<a name="216175454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216175454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216175454">(Nov 10 2020 at 06:10)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> Thanks, but unless the comments in config.toml.example are wrong, the configuration should be set. And <code>-vv</code> doesn't show any debug messages either, FYI. I'm not setting <code>debug-logging = true</code> explicitly, but I have <code>debug = true</code>, which supposedly implies <code>debug_assertions</code>, which implies <code>debug_logging</code>. The debug messages do show up when I run <code>rustc</code> directly. But using the same build (with only the test code being recompiled) the debug messages and debug assertions do not show up.</p>



<a name="216178903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216178903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216178903">(Nov 10 2020 at 07:31)</a>:</h4>
<p>To be more clear hopefully, <code>debug_assert!(false)</code> should panic, but it doesn't. So it's not log messages being swallowed. They aren't being generated.</p>



<a name="216296224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296224">(Nov 11 2020 at 01:05)</a>:</h4>
<p>I tried explicitly setting <code>debug-logging=true</code> but still got no logs (with or without <code>-vv</code>).</p>



<a name="216296343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296343">(Nov 11 2020 at 01:07)</a>:</h4>
<p>I think I see that <code>debug_assert!()</code> and <code>debug!()</code> macros are compiled in or out based on different criteria, so <code>-C debug-assertions=on</code> (if I could set it) would enable the former macro, but not the latter (logs).</p>



<a name="216296547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296547">(Nov 11 2020 at 01:10)</a>:</h4>
<p>FYI, I was able to enable <code>debug-assertions</code> by changing bootstrap/test.rs. The in-tree tests do ignore the <code>--rustc-args</code> flag. That flag is only passed to <code>compiletest</code>. Unfortunately, a side effect of that change was, every time I ran <code>./x.py test ...</code>, cargo recompiled all of <code>rustc</code>. That's probably why <code>--rustc-args</code> was not applied to in-tree tests in the first place. Sucks to lose that option though.</p>



<a name="216296911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296911">(Nov 11 2020 at 01:14)</a>:</h4>
<p>But it's really hard to figure out what to set or change to enable the debug logs. A "profile" (or "CARGO_PROFILE_..." environment variable)? Or a "max_level_..." feature for setting the max log level? Something else? I just don't quite follow where the defaults are getting set or where the best place to override them would be.</p>



<a name="216296971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296971">(Nov 11 2020 at 01:15)</a>:</h4>
<p>(I also realize the topic title was wrong, since I really don't care as much about enabling debug assertions as I do about debug logging. Sorry.)</p>



<a name="216296987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296987">(Nov 11 2020 at 01:15)</a>:</h4>
<p>I'm still confused why logging + assertions isn't getting enabled by normal <code>debug-assertions = true</code></p>



<a name="216296994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216296994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216296994">(Nov 11 2020 at 01:15)</a>:</h4>
<p>what command are you using to test?</p>



<a name="216297054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297054">(Nov 11 2020 at 01:16)</a>:</h4>
<p>Mentioned in original message: <br>
The command I use to run tests and see the stdout/stderr is: RUSTC_LOG="rustc_mir::transform::coverage=debug" ./x.py test compiler/rustc_mir --rustc-args "-C debug-assertions=on" --test-args "--show-output coverage"</p>



<a name="216297064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297064">(Nov 11 2020 at 01:16)</a>:</h4>
<p>oh I see you're running unit tests</p>



<a name="216297072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297072">(Nov 11 2020 at 01:16)</a>:</h4>
<p>yes</p>



<a name="216297106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297106">(Nov 11 2020 at 01:17)</a>:</h4>
<p>wait, so you mean that logs and asserts <em>in the unit tests</em> aren't running?</p>



<a name="216297110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297110">(Nov 11 2020 at 01:17)</a>:</h4>
<p>as opposed to asserts in the compiler?</p>



<a name="216297112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297112">(Nov 11 2020 at 01:17)</a>:</h4>
<p>appears so</p>



<a name="216297122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297122">(Nov 11 2020 at 01:17)</a>:</h4>
<p>ok, the issue with logging is probably that you haven't registered a logger</p>



<a name="216297179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297179">(Nov 11 2020 at 01:18)</a>:</h4>
<p>try calling <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.init_rustc_env_logger.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.init_rustc_env_logger.html</a></p>



<a name="216297189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297189">(Nov 11 2020 at 01:18)</a>:</h4>
<p>Is that a normal thing to do when writing unit tests in the compiler?</p>



<a name="216297199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297199">(Nov 11 2020 at 01:18)</a>:</h4>
<p>well writing unit tests is itself pretty unusual <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="216297209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297209">(Nov 11 2020 at 01:18)</a>:</h4>
<p>not sure about asserts but that makes more sense why they aren't being enabled, tests are compiled separately from the compiler itself</p>



<a name="216297307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297307">(Nov 11 2020 at 01:20)</a>:</h4>
<p>are you using <code>assert!</code> or <code>debug_assert!</code>?</p>



<a name="216297319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297319">(Nov 11 2020 at 01:20)</a>:</h4>
<p>I would make it <code>assert!</code> unconditionally if it's just a test</p>



<a name="216297337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297337">(Nov 11 2020 at 01:21)</a>:</h4>
<blockquote>
<p>well writing unit tests is itself pretty unusual<br>
true</p>
</blockquote>



<a name="216297404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297404">(Nov 11 2020 at 01:22)</a>:</h4>
<p>sorry, it was misleading to talk about debug_assert!() when trying to explain my symptom. Ignore that.</p>



<a name="216297418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297418">(Nov 11 2020 at 01:22)</a>:</h4>
<p>rustc_mir Cargo.toml doesn't include rustc_driver, so I'll have to add that I guess</p>



<a name="216297427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297427">(Nov 11 2020 at 01:22)</a>:</h4>
<p>rustc_ dependencies don't go in cargo.toml</p>



<a name="216297436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297436">(Nov 11 2020 at 01:23)</a>:</h4>
<p>use <code>extern crate rustc_driver;</code> instead</p>



<a name="216297440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297440">(Nov 11 2020 at 01:23)</a>:</h4>
<p>they're loaded from the sysroot</p>



<a name="216297456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297456">(Nov 11 2020 at 01:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustdoc/lib.rs#L24-L30">https://github.com/rust-lang/rust/blob/master/src/librustdoc/lib.rs#L24-L30</a></p>



<a name="216297460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297460">(Nov 11 2020 at 01:23)</a>:</h4>
<p>OK cool... but specifically I was looking at compiler/rustc_mir/Cargo.toml</p>



<a name="216297469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297469">(Nov 11 2020 at 01:24)</a>:</h4>
<p>right, yes, it won't be there</p>



<a name="216297526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297526">(Nov 11 2020 at 01:24)</a>:</h4>
<p>although hmm you have a dependency issue that rustc_driver itself depends on rustc_mir</p>



<a name="216297538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297538">(Nov 11 2020 at 01:24)</a>:</h4>
<p>so you probably need to copy the implementation of <code>init_env_logger</code></p>



<a name="216297552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297552">(Nov 11 2020 at 01:25)</a>:</h4>
<p>ok</p>



<a name="216297571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297571">(Nov 11 2020 at 01:25)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116122">@simulacrum</span> - is there a simple way to get debug logging in unit tests? right now the output is <em>logged</em> but not <em>emitted</em> because the logger is never initialized</p>



<a name="216297656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297656">(Nov 11 2020 at 01:26)</a>:</h4>
<p>Nope, tests need to init the logger if they want output. It's AFAIK basically an unsolved problem at this point in rust</p>



<a name="216297670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297670">(Nov 11 2020 at 01:26)</a>:</h4>
<p>got it</p>



<a name="216297677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297677">(Nov 11 2020 at 01:27)</a>:</h4>
<p>thank you</p>



<a name="216297686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297686">(Nov 11 2020 at 01:27)</a>:</h4>
<p>(it's possibly one reason unit tests are not super popular in rustc)</p>



<a name="216297695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297695">(Nov 11 2020 at 01:27)</a>:</h4>
<p>That said, if you have a specific test it should be like one line to add I think</p>



<a name="216297702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297702">(Nov 11 2020 at 01:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> unfortunately not, because <code>init_logger</code> is only in <code>rustc_driver</code></p>



<a name="216297709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297709">(Nov 11 2020 at 01:27)</a>:</h4>
<p><a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests/near/216297526">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests/near/216297526</a></p>



<a name="216297757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297757">(Nov 11 2020 at 01:28)</a>:</h4>
<p>Sure yeah :/</p>



<a name="216297778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297778">(Nov 11 2020 at 01:29)</a>:</h4>
<p><span class="user-mention" data-user-id="296355">@Rich Kadel</span> are these <em>unit unit</em> tests or in, say, rustc_mir/tests/foo.rs?</p>



<a name="216297811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297811">(Nov 11 2020 at 01:29)</a>:</h4>
<p>for the latter, rustc_driver would likely work today I think (though it's arguably a bug depending on how you look at it)</p>



<a name="216297915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216297915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216297915">(Nov 11 2020 at 01:31)</a>:</h4>
<p>I'm trying to address a review feedback requests to add unit tests (not sure if you'd call them <em>unit unit tests</em> ;-) ) to some of the more complex parts of the rust coverage algorithms in <code>rustc_mir/transform/coverage</code>, new submodule <code>tests.rs</code></p>



<a name="216298044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298044">(Nov 11 2020 at 01:33)</a>:</h4>
<p>where is <code>rustc_mir/tests</code>? Or is that something that, if I added it, you think it would work?</p>



<a name="216298054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298054">(Nov 11 2020 at 01:34)</a>:</h4>
<p>right, so the rustc_mir/tests directory would basically be the equivalent of a ui-fulldeps test</p>



<a name="216298095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298095">(Nov 11 2020 at 01:34)</a>:</h4>
<p>in terms of what it can do</p>



<a name="216298105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298105">(Nov 11 2020 at 01:34)</a>:</h4>
<p>today, anyway, in the long term it'll be more limited</p>



<a name="216298113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298113">(Nov 11 2020 at 01:34)</a>:</h4>
<p>I think probably I would recommend that you go for the copy/paste of the init_logger function from rustc_driver</p>



<a name="216298124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298124">(Nov 11 2020 at 01:34)</a>:</h4>
<p>or feel free to move it to like rustc_data_structures, too</p>



<a name="216298155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298155">(Nov 11 2020 at 01:35)</a>:</h4>
<p>(the more limited is fixing the bug that I mentioned -- currently tests for rustc crates depend on the entire rustc build in rustbuild, AFAIK, which isn't actually necessary)</p>



<a name="216298160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298160">(Nov 11 2020 at 01:35)</a>:</h4>
<p>right, I'm leaning that way ... Thanks</p>



<a name="216298164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298164">(Nov 11 2020 at 01:35)</a>:</h4>
<p>(deleted)</p>



<a name="216298183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298183">(Nov 11 2020 at 01:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests/near/216298155">said</a>:</p>
<blockquote>
<p>(the more limited is fixing the bug that I mentioned -- currently tests for rustc crates depend on the entire rustc build in rustbuild, AFAIK, which isn't actually necessary)</p>
</blockquote>
<p>ohhhh, yeah that would be nice to fix</p>



<a name="216298240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298240">(Nov 11 2020 at 01:36)</a>:</h4>
<p>I think we talked about <code>test library/core</code> not having to build std at some point, too</p>



<a name="216298257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298257">(Nov 11 2020 at 01:36)</a>:</h4>
<p>err maybe not test but <code>build</code></p>



<a name="216298271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298271">(Nov 11 2020 at 01:36)</a>:</h4>
<p>er, well, perhaps both depending on the way you draw arrows</p>



<a name="216298286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298286">(Nov 11 2020 at 01:36)</a>:</h4>
<p>build is "easy" in some sense, test is more, uh, unclear</p>



<a name="216298296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298296">(Nov 11 2020 at 01:37)</a>:</h4>
<p>yeah I gave up on getting test to work for <code>clippy</code></p>



<a name="216298304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298304">(Nov 11 2020 at 01:37)</a>:</h4>
<p>I think there's two versions of <code>std</code> or something like that?</p>



<a name="216298444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298444">(Nov 11 2020 at 01:39)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> - Just so I'm clear, I do need to bring <code>tracing</code> into <code>rustc_mir/Cargo.toml</code> (or <code>rustc_data_structures</code> or wherever), right?</p>



<a name="216298492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298492">(Nov 11 2020 at 01:40)</a>:</h4>
<p>I would <em>expect</em> you to be able to load it from sysroot</p>



<a name="216298507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298507">(Nov 11 2020 at 01:40)</a>:</h4>
<p>so try that first and if it doesn't work, then try dev-dependencies in cargo.toml</p>



<a name="216298516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298516">(Nov 11 2020 at 01:40)</a>:</h4>
<p>don't put it in the main dependencies though</p>



<a name="216298519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298519">(Nov 11 2020 at 01:40)</a>:</h4>
<div class="codehilite"><pre><span></span><code>  --&gt; compiler/rustc_mir/src/transform/coverage/tests.rs:12:1
   |
12 | extern crate tracing;
</code></pre></div>



<a name="216298528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298528">(Nov 11 2020 at 01:40)</a>:</h4>
<p>error[E0468]: an <code>extern crate</code> loading macros must be at the crate root</p>



<a name="216298548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298548">(Nov 11 2020 at 01:41)</a>:</h4>
<p>ok, so put <code>extern crate tracing</code> in <code>src/lib.rs</code> with <code>cfg(test)</code></p>



<a name="216298553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298553">(Nov 11 2020 at 01:41)</a>:</h4>
<p>maybe i don't need #[macro_use]</p>



<a name="216298561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298561">(Nov 11 2020 at 01:41)</a>:</h4>
<p>or that, yeah</p>



<a name="216298594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298594">(Nov 11 2020 at 01:41)</a>:</h4>
<p>haha, well, now debug! is not recognized</p>



<a name="216298643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298643">(Nov 11 2020 at 01:42)</a>:</h4>
<p><code>use tracing::debug;</code></p>



<a name="216298655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298655">(Nov 11 2020 at 01:42)</a>:</h4>
<p>er you should definitely be putting tracing in Cargo.toml for rustc_mir</p>



<a name="216298664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216298664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216298664">(Nov 11 2020 at 01:42)</a>:</h4>
<p>indeed, it's already there</p>



<a name="216299404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299404">(Nov 11 2020 at 01:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> - thinking about where to put this eventually, is there any "test driver" code in rustc that gets executed before a <code>test_...</code> function starts? (Just, if so, that might be a good place to put this init logging stuff.)</p>



<a name="216299427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299427">(Nov 11 2020 at 01:55)</a>:</h4>
<p>no, there isn't</p>



<a name="216299428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299428">(Nov 11 2020 at 01:55)</a>:</h4>
<p><span class="user-mention" data-user-id="296355">@Rich Kadel</span> not that I know of - there's no entrypoint, the test function <em>is</em> the entrypoint</p>



<a name="216299432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299432">(Nov 11 2020 at 01:55)</a>:</h4>
<p>it literally needs to go in each #[test] function</p>



<a name="216299435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299435">(Nov 11 2020 at 01:55)</a>:</h4>
<p>makes sense, ok</p>



<a name="216299480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299480">(Nov 11 2020 at 01:56)</a>:</h4>
<p>it's not the entry point, but the entry point is synthesized by the compiler (basically a big main function calling a bunch of other stuff)</p>



<a name="216299504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216299504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216299504">(Nov 11 2020 at 01:56)</a>:</h4>
<p>it's sort of desirable to have "before each test" and "on startup" functions in unit tests, but custom test frameworks and generally libtest ergonomics have long lacked a driver/interested party</p>



<a name="216300050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300050">(Nov 11 2020 at 02:04)</a>:</h4>
<p><code>extern crate tracing_subscriber;</code> or <code>use ...</code> for that, doesn't work from the tests, but appears necessary. I <em>think</em> I need to add it to <code>rustc_mir/Cargo.toml</code> (replicating what's in <code>rustc_driver/Config.toml</code>. Yes?</p>



<a name="216300060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300060">(Nov 11 2020 at 02:04)</a>:</h4>
<p>yes, the same way tracing is now</p>



<a name="216300082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300082">(Nov 11 2020 at 02:05)</a>:</h4>
<p>yep that sounds correct</p>



<a name="216300088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300088">(Nov 11 2020 at 02:05)</a>:</h4>
<p>you could add it to dev-deps in Cargo.toml though (new section)</p>



<a name="216300090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300090">(Nov 11 2020 at 02:05)</a>:</h4>
<p>since it's not needed for main build</p>



<a name="216300094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216300094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216300094">(Nov 11 2020 at 02:05)</a>:</h4>
<p>indeed, I would say "should"</p>



<a name="216302150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302150">(Nov 11 2020 at 02:43)</a>:</h4>
<p>Hmm... I'm not sure what to do with this logger init...</p>
<p>Logging works for the first test, but panics for all others.</p>
<p>I tried initializing at the start of each test, and also tried initializing ONLY once. Different errors in each case, but the same result. Only one test works, and the rest panic.</p>
<p>If I call it at the start of each test, all but the first test panic with:</p>
<div class="codehilite"><pre><span></span><code>thread &#39;transform::coverage::tests::test_covgraph_switchint_loop_then_inner_loop_else_break&#39; panicked at &#39;no ImplicitCtxt stored in tls&#39;, compiler/rustc_middle/src/ty/context.rs:1747:54
</code></pre></div>
<p>If I call it only once, all but the first test panic with:</p>
<div class="codehilite"><pre><span></span><code>thread &#39;transform::coverage::tests::test_covgraph_goto_switchint&#39; panicked at &#39;called `Result::unwrap()` on an `Err` value: &quot;PoisonError { inner: .. }&quot;&#39;, /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-tree-0.1.6/src/lib.rs:312:42
</code></pre></div>



<a name="216302257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302257">(Nov 11 2020 at 02:45)</a>:</h4>
<p>Wait.. the first error is wrong</p>



<a name="216302280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302280">(Nov 11 2020 at 02:46)</a>:</h4>
<p>Copied the wrong one. The logger error I got when initializing for each test was:</p>
<div class="codehilite"><pre><span></span><code>thread &#39;transform::coverage::tests::test_find_loop_backedges_two&#39; panicked at &#39;called `Result::unwrap()` on an `Err` value: SetGlobalDefaultError { _no_construct: () }&#39;, compiler/rustc_mir/src/transform/coverage/tests.rs:51:57
</code></pre></div>



<a name="216302371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302371">(Nov 11 2020 at 02:47)</a>:</h4>
<p>That error comes from the only <code>tracing::</code> call in the initializer:</p>
<div class="codehilite"><pre><span></span><code>   tracing::subscriber::set_global_default(subscriber).unwrap();
</code></pre></div>



<a name="216302444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302444">(Nov 11 2020 at 02:48)</a>:</h4>
<p>So it seems like I can only call <code>set_global_default</code> once, but when I do that, I get the <code>PoisonError</code></p>



<a name="216302481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302481">(Nov 11 2020 at 02:49)</a>:</h4>
<p>don't call unwrap</p>



<a name="216302482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302482">(Nov 11 2020 at 02:49)</a>:</h4>
<p>and then you'll be good :)</p>



<a name="216302662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302662">(Nov 11 2020 at 02:53)</a>:</h4>
<p>Well, all that does is ignore the Err that's returned. Since setting the global default fails, it has the same effect as not calling it at all (after the first call), and results in the <code>PoisonError</code> again.</p>



<a name="216302675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302675">(Nov 11 2020 at 02:53)</a>:</h4>
<p>shouldn't it already be set from the first call?</p>



<a name="216302715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302715">(Nov 11 2020 at 02:54)</a>:</h4>
<p>I think it is, which is why the others fail.</p>



<a name="216302734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302734">(Nov 11 2020 at 02:54)</a>:</h4>
<p>so there you go</p>



<a name="216302738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302738">(Nov 11 2020 at 02:54)</a>:</h4>
<p>you accomplished the goal</p>



<a name="216302740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302740">(Nov 11 2020 at 02:54)</a>:</h4>
<p>not all errors need to be handled</p>



<a name="216302743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302743">(Nov 11 2020 at 02:55)</a>:</h4>
<p>?</p>



<a name="216302766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302766">(Nov 11 2020 at 02:55)</a>:</h4>
<p>It panics calling <code>debug!()</code></p>



<a name="216302773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302773">(Nov 11 2020 at 02:55)</a>:</h4>
<p>on all but the first test</p>



<a name="216302775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302775">(Nov 11 2020 at 02:55)</a>:</h4>
<p>oh I see, I was missing that info <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="216302776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302776">(Nov 11 2020 at 02:55)</a>:</h4>
<p>sorry</p>



<a name="216302935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302935">(Nov 11 2020 at 02:59)</a>:</h4>
<p>More context:</p>



<a name="216302939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216302939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216302939">(Nov 11 2020 at 02:59)</a>:</h4>
<div class="codehilite"><pre><span></span><code>  16:     0x7fb14717c503 - core::result::unwrap_failed::h46151a4246fa4cac
                               at /usr/local/google/home/richkadel/rust/library/core/src/result.rs:1220:5
  17:     0x55b6fe8921be - &lt;tracing_tree::HierarchicalLayer&lt;W&gt; as tracing_subscriber::layer::Layer&lt;S&gt;&gt;::on_event::h15bbdc22078f1087
  18:     0x55b6fedcd982 - tracing_core::dispatcher::Dispatch::event::hcf30211326094ac1
                               at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.17/src/dispatcher.rs:523:9
  19:     0x55b6fedcd982 - tracing_core::event::Event::dispatch::{{closure}}::hfecfa902ad865e1f
                               at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.17/src/event.rs:35:13
  20:     0x55b6fedcd982 - tracing_core::dispatcher::get_default::{{closure}}::he826e8d88610a083
                               at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.17/src/dispatcher.rs:337:24
  21:     0x55b6fedcd982 - std::thread::local::LocalKey&lt;T&gt;::try_with::h9dc94c9698529097
                               at /usr/local/google/home/richkadel/rust/library/std/src/thread/local.rs:272:16
  22:     0x55b6fedcd982 - tracing_core::dispatcher::get_default::h7368a7ced1dab37b
                               at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.17/src/dispatcher.rs:334:5
  23:     0x55b6fedce2b1 - tracing_core::event::Event::dispatch::he7cabf3e4b562110
                               at /usr/local/google/home/richkadel/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.17/src/event.rs:34:9
  24:     0x55b6fe87dc13 - rustc_mir::transform::coverage::graph::CoverageGraph::add_basic_coverage_block::hf08e034e1316d5a3
</code></pre></div>



<a name="216303006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216303006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216303006">(Nov 11 2020 at 03:00)</a>:</h4>
<p>I don't think this is something I can help with, I would ask in the tracing repo</p>



<a name="216303012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216303012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216303012">(Nov 11 2020 at 03:00)</a>:</h4>
<p><a href="https://github.com/tokio-rs/tracing/">https://github.com/tokio-rs/tracing/</a></p>



<a name="216303016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216303016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216303016">(Nov 11 2020 at 03:00)</a>:</h4>
<p>ok, thanks for getting me this far!</p>



<a name="216304215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216304215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216304215">(Nov 11 2020 at 03:28)</a>:</h4>
<p><span class="user-mention" data-user-id="296355">@Rich Kadel</span> might be enough to just add a static Once to the init function in driver or wherever we've put it now and bail out</p>



<a name="216304224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216304224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216304224">(Nov 11 2020 at 03:28)</a>:</h4>
<p>That should be fine</p>



<a name="216304337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216304337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216304337">(Nov 11 2020 at 03:30)</a>:</h4>
<p>Sounds good. </p>
<p>I think the PoisonError may be my fault, actually. May not be related to the logger init. So I'll clean that up and if I get it working, I'll push a PR for this API.</p>



<a name="216307695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/enabling%20debug%20logging%20for%20rustc%20in-tree%20tests/near/216307695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/enabling.20debug.20logging.20for.20rustc.20in-tree.20tests.html#216307695">(Nov 11 2020 at 04:52)</a>:</h4>
<p>Thanks again for the advice. Unfortunately, I now realize that enabling the debug logs is not going to work for my test cases because some of the debug logs print MIR objects that leverage global context variables that my tests don't attempt to initialize. </p>
<p>(As Joshua was saying, there may be reasons like this that unit tests are rare in the compiler.)</p>
<p>It's more trouble than it's worth for me at this point, sadly. But that's OK.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>